package com.es.aspect;

import org.aspectj.lang.ProceedingJoinPoint;

//切面就是一个连接点集合
public class ServiceAspect {

    public void beginTranscation() {
        System.out.println("开启事务");
    }

    public void commitTranscation() {
        System.out.println("提交事务");
    }

    public void exceptionAdvice(Throwable ex) {
        System.out.println("出异常了");
        System.out.println("事务回滚");
    }

    public void finallyAdvice(Object result) {
        System.out.println("方法最后的返回值是：" + result);
    }


    public Object aroundAdvice(ProceedingJoinPoint joinPoint) {
        Object target = joinPoint.getTarget();
        System.out.println("我代理的对象是：" + target);
        try {
           return joinPoint.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return null;
    }
}
